//
//  LoginViewController.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/2.
//  Copyright © 2019 李文强. All rights reserved.
//

#import "LoginViewController.h"
#import "MinButtonViewBtn.h"
#import "ForgetViewController.h"
#import "MainNavigationController.h"
#import "ViewController.h"
#import "UserInformationModel.h"
//信鸽
#import "XGPush.h"


@interface LoginViewController ()<CAAnimationDelegate,UITextFieldDelegate>
@property (nonatomic, strong) UILabel *titleLable;
@property (nonatomic, strong) UIView *lineCountView;
@property (nonatomic, strong) UIView *linePassView;
@property (nonatomic, strong) UIImageView *acountImageView;
@property (nonatomic, strong) UIImageView *passwordImageView;
@property (nonatomic, strong) UIButton *acountMoreButton;
@property (nonatomic, strong) UIButton *passMoreButton;
@property (nonatomic, strong) UIButton *passEarButton;
@property (nonatomic, strong) UIView *topLineView;
@property (nonatomic, strong) UIView *bottomLineVIew;
@property (nonatomic, strong) UIButton *loginButton;
@property (nonatomic, strong) MinButtonViewBtn *remamberButton;
@property (nonatomic, strong) UIButton *rightForgetButton;
@property (nonatomic, strong) ForgetViewController *forgetVC;
@property (nonatomic, strong) UITextField *acountTF;
@property (nonatomic, strong) UITextField *passTF;
@property (nonatomic, strong) UserInformationModel *userInfoModel;

@end

@implementation LoginViewController
- (void)viewWillAppear:(BOOL)animated{
    self.navigationController.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBar.hidden = YES;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (UITextField *)acountTF{
    if (!_acountTF) {
        UITextField *tf = [[UITextField alloc]init];
        tf.placeholder = @"账号名格式: 姓名@sy31";
        tf.textColor = TITLECOLOR;
        tf.delegate = self;
        NSString *phone = [USERDEFAL objectForKey:AcountDefalut];
        if (phone.length>0) {
            tf.text = phone;
        }else{
//            tf.text = @"单茹@sy31";
            tf.text = @"";
        }
        _acountTF = tf;

//        _acountTF.text =  @"闫彩艳@sy31";//@"单茹@sy31";


//        _acountTF.text = @"王红蕾@sy31";


    }
    return _acountTF;
}
- (UITextField *)passTF{
    if (!_passTF) {
        UITextField *tf = [[UITextField alloc]init];
        tf.placeholder = @"请输入密码";
        tf.textColor = TITLECOLOR;
        tf.secureTextEntry = YES;
        tf.delegate = self;
        NSString *pass = [USERDEFAL objectForKey:PassDefalut];
        if (pass.length>0) {
            tf.text = pass;
        }else{
            tf.text = @"888888";
            tf.text = @"";
        }
        _passTF = tf;
    }
    return _passTF;
}
- (UIImageView *)imageView{
    if (!_imageView) {
        UIImageView *imageV = [[UIImageView alloc]init];
        imageV.image = [UIImage imageNamed:@"login"];
        _imageView = imageV;
    }
    return _imageView;
}
- (UIImageView *)logoImageView{
    if (!_logoImageView) {
        UIImageView *imageV = [[UIImageView alloc]init];
        imageV.image = [UIImage imageNamed:@"logo"];
        _logoImageView = imageV;
    }
    return _logoImageView;
}
- (UILabel *)welcomeLabel{
    if (!_welcomeLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(44.5,375.5,147.5,23);
        label.numberOfLines = 0;
        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"WELOME" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang-SC-Medium" size: 30],NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]}];
        label.attributedText = string;
        _welcomeLabel = label;
    }
    return _welcomeLabel;
}
- (UIImageView *)linViewImage{
    if (!_linViewImage) {
        UIImageView *imageV = [[UIImageView alloc]init];
        imageV.image = [UIImage imageNamed:@"line_login"];
        _linViewImage = imageV;
    }
    return _linViewImage;
}
- (UIView *)backView{
    if (!_backView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = [UIColor whiteColor];
        _backView = view;
    }
    return _backView;
}
- (UIView *)linePassView{
    if (!_linePassView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = [UIColor whiteColor];
        _linePassView = view;
    }
    return _linePassView;
}
- (UIView *)lineCountView{
    if (!_lineCountView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = [UIColor whiteColor];
        _lineCountView = view;
    }
    return _lineCountView;
}
- (UILabel *)titleLable{
    if (!_titleLable) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(750.5,173.5,92.5,22.5);
        label.numberOfLines = 1;
        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"用户登录" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang-SC-Medium" size: 24],NSForegroundColorAttributeName: [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]}];
        label.attributedText = string;
        _titleLable = label;
    }
    return _titleLable;
}
- (UIImageView *)titleLineImageView{
    if (!_titleLineImageView) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.image = [UIImage imageNamed:@"image_line"];
        _titleLineImageView = imageView;
    }
    return _titleLineImageView;
}
- (UIImageView *)acountImageView{
    if (!_acountImageView) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.image = [UIImage imageNamed:@"acount"];
        _acountImageView = imageView;
    }
    return _acountImageView;
}
- (UIImageView *)passwordImageView{
    if (!_passwordImageView) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.image = [UIImage imageNamed:@"pass"];
        _passwordImageView = imageView;
    }
    return _passwordImageView;
}
//ear_image
- (UIButton *)acountMoreButton{
    if (!_acountMoreButton) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:[UIImage imageNamed:@"arrow_down"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(acountMoreButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        _acountMoreButton = button;
    }
    return _acountMoreButton;
}
- (UIButton *)passMoreButton{
    if (!_passMoreButton) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setBackgroundImage:[UIImage imageNamed:@"arrow_down"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(passMoreButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        _passMoreButton = button;
    }
    return _passMoreButton;
}
- (UIButton *)passEarButton{
    if (!_passEarButton) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setBackgroundImage:[UIImage imageNamed:@"ear_image"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(passEarButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        _passEarButton = button;
    }
    return _passEarButton;
}
- (UIView *)topLineView{
    if (!_topLineView) {
        UIView *view = [[UIView alloc]init];
        view.frame = CGRectMake(654,321,285,1);
        view.backgroundColor = [UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1.0];
        view.layer.cornerRadius = 0.5;
        _topLineView = view;
    }
    return _topLineView;
}
- (UIView *)bottomLineVIew{
    if (!_bottomLineVIew) {
        UIView *view = [[UIView alloc]init];
        view.frame = CGRectMake(654,321,285,1);
        view.backgroundColor = [UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1.0];
        view.layer.cornerRadius = 0.5;
        _bottomLineVIew = view;
    }
    return _bottomLineVIew;
}
- (UIButton *)loginButton{
    if (!_loginButton) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [button setTitle:@"登录" forState:UIControlStateNormal];
        [button setBackgroundImage:[UIImage imageNamed:@"login_back"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(loginClick:) forControlEvents:UIControlEventTouchUpInside];
        _loginButton = button;
    }
    return _loginButton;
}
- (MinButtonViewBtn *)remamberButton{
    if (!_remamberButton) {
        MinButtonViewBtn *but = [[MinButtonViewBtn alloc]initWithFrame:CGRectMake(0, 0, 90, 12) andType:ButtonImageInLeft];
        but.bottomLabel.text = @"记住登录信息";
        but.bottomLabel.font = [UIFont systemFontOfSize:12];
        but.topImage.image = [UIImage imageNamed:@"remanber"];
        if ([[USERDEFAL objectForKey:RemaberButtonStateDefalut] isEqualToString:@"YES"]) {
            but.selected = YES;
            but.topImage.image = [UIImage imageNamed:@"selecSquir"];
        }else{
            but.selected = NO;
            but.topImage.image = [UIImage imageNamed:@"remanber"];
        }
        [but addTarget:self action:@selector(remanberClick:) forControlEvents:UIControlEventTouchUpInside];
        _remamberButton = but;
    }
    return _remamberButton;
}
- (UIButton *)rightForgetButton{
    if (!_rightForgetButton) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitleColor:TITLECOLOR forState:UIControlStateNormal];
        [button setTitle:@"忘记密码" forState:UIControlStateNormal];
        [button addTarget:self action:@selector(forgetClick:) forControlEvents:UIControlEventTouchUpInside];
        button.titleLabel.font = [UIFont systemFontOfSize:12];
        button.selected = NO;
        _rightForgetButton = button;
    }
    return _rightForgetButton;
}

//- (void)loginClick:(UIButton *)sender{
//    [self.navigationController removeFromParentViewController];
//    ViewController *loginHomePageVC = [[ViewController alloc] init];
//    MainNavigationController *nav = [[MainNavigationController alloc]initWithRootViewController:loginHomePageVC];
//    [UIApplication sharedApplication].keyWindow.rootViewController = nav;
////    [MBProgressHUD mj_showLoading];
////    [SYRequestAPI sy_loginServiceAccount:@"13014518277" password:@"123456" success:^(BOOL isSuccess) {
////        [MBProgressHUD mj_hideHUD];
////
////
////    } fail:^(NSError *error) {
////        [MBProgressHUD mj_hideHUD];
////        [MBProgressHUD mj_showError:error.domain];
////    }];
//}

- (void)textFieldDidEndEditing:(UITextField *)textField{
    if (textField.text.length>0) {
        if (textField == _acountTF) {
            //账号
            [USERDEFAL setObject:_acountTF.text forKey:AcountDefalut];
        }else{
            //密码
            [USERDEFAL setObject:_passTF.text forKey:PassDefalut];
        }
    }
}


#pragma mark - 忘记密码
- (void)forgetClick:(UIButton *)sender{
//    dispatch_async(dispatch_queue_create(0, 0), ^{
//        // 子线程执行任务（比如获取较大数据）
    //        loginView.modalPresentationStyle = UIModalPresentationOverFullScreen;
    //        loginView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    //        dispatch_async(dispatch_get_main_queue(), ^{
    //            // 通知主线程刷新
    //            loginView.view.frame = self.view.frame;
    //            [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:loginView animated:YES completion:nil];
    //
    //        });
    //    });
//    if (_remamberButton.selected == YES) {
        if (_acountTF.text.length>0) {
            [USERDEFAL setObject:_acountTF.text forKey:AcountDefalut];
        }
        if (_passTF.text.length>0) {
            [USERDEFAL setObject:_passTF.text forKey:PassDefalut];
        }
//    }
        ForgetViewController *loginView = [[ForgetViewController alloc]init];
        loginView.view.backgroundColor = [UIColor whiteColor];
        [self.navigationController pushViewController:loginView animated:YES];

}

- (void)initSubView{
    self.view.frame = CGRectMake(0, 0, APP_WIDTH, APP_HEIGHT);
    self.view.backgroundColor = [UIColor whiteColor];
    [[NSNotificationCenter defaultCenter]postNotificationName:@"HideTabbarNoti" object:nil];
    [self.view addSubview:self.imageView];
    [self.view addSubview:self.logoImageView];
    [self.view addSubview:self.welcomeLabel];
    [self.view addSubview:self.linViewImage];
    [self.view addSubview:self.backView];
    [_backView addSubview:self.titleLable];
    [_backView addSubview:self.titleLineImageView];
    [_backView addSubview:self.topLineView];
    [_backView addSubview:self.bottomLineVIew];
    //账号输入
    [_backView addSubview:self.acountTF];
    
    [_backView addSubview:self.acountImageView];
    [_backView addSubview:self.passwordImageView];
    [_backView addSubview:self.acountMoreButton];
    [_backView addSubview:self.passMoreButton];
    [_backView addSubview:self.passEarButton];
    [_backView addSubview:self.loginButton];
    //密码输入
    [_backView addSubview:self.passTF];
    
    [_backView addSubview:self.remamberButton];
    [_backView addSubview:self.rightForgetButton];
//    [self getVersion];
}

- (void)willRemoveSubview{
//    self.forgetVC.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.width);
//    [UIView animateWithDuration:0.5 animations:^{
//        self.forgetVC.view.frame = CGRectMake(self.view.frame.size.width, 0, self.view.frame.size.width, self.view.frame.size.width);
//    } completion:^(BOOL finished) {
//        [self.forgetVC.view removeFromSuperview];
//    }];
    
}

- (void)initOption{
    NSString *token = Token;
    if (token.length >0) {
        //直接登录
        
        
        [self loginNoClick];
    }else{
        NSLog(@"Token IS Null");
    }
}
- (void)layout{
    CGFloat W = 560*fw;
    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.width.equalTo(@0).offset(W);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
    [_logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0).offset(51*fw);
        make.width.equalTo(@0).offset(191*fw);
        make.height.equalTo(@73);
        make.top.equalTo(@0).offset(148*fh);
    }];
    [_welcomeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.logoImageView.mas_left);
        make.top.equalTo(self.logoImageView.mas_bottom).offset(155*fh);
        make.width.equalTo(@150);
        make.height.equalTo(@30);
    }];
    [_linViewImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.welcomeLabel.mas_left);
        make.width.equalTo(@0).offset(50*fw);
        make.height.equalTo(@5);
        make.top.equalTo(self.welcomeLabel.mas_bottom).offset(20);
    }];
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageView.mas_right);
        make.right.equalTo(@0);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
    [_titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.backView.mas_centerX);
        make.top.equalTo(@0).offset(174*fh);
        make.width.equalTo(@100);
        make.height.equalTo(@23);
    }];
    [_titleLineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.backView.mas_centerX);
        make.top.equalTo(self.titleLable.mas_bottom).offset(7*fh);
        make.width.equalTo(@0).offset(45*fw);
        make.height.equalTo(@2);
    }];
    [_topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0).offset(94*fw);
        make.right.equalTo(@0).offset(-85*fw);
        make.height.equalTo(@1);
        make.top.equalTo(self.titleLineImageView.mas_bottom).offset(125*fh);
    }];
    [_bottomLineVIew mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0).offset(94*fw);
        make.right.equalTo(@0).offset(-85*fw);
        make.height.equalTo(@1);
        make.top.equalTo(self.topLineView.mas_bottom).offset(70*fh);
    }];
    [_acountImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.topLineView.mas_left);
        make.width.equalTo(@18);
        make.height.equalTo(@18);
        make.bottom.equalTo(self.topLineView.mas_bottom).offset(-13);
    }];
    [_passwordImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomLineVIew.mas_left);
        make.width.equalTo(@18);
        make.height.equalTo(@18);
        make.bottom.equalTo(self.bottomLineVIew.mas_bottom).offset(-13);
    }];
    [_acountMoreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.topLineView.mas_right);
        make.centerY.equalTo(self.acountImageView.mas_centerY);
        make.width.equalTo(@15);
        make.height.equalTo(@8);
    }];
    [_passEarButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bottomLineVIew.mas_right);
        make.centerY.equalTo(self.passwordImageView.mas_centerY);
        make.width.equalTo(@15);
        make.height.equalTo(@12);
    }];
    [_passMoreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.passEarButton.mas_left).offset(-5);
        make.centerY.equalTo(self.passwordImageView.mas_centerY);
        make.width.equalTo(@15);
        make.height.equalTo(@8);
    }];
    [_loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.backView.mas_centerX);
        make.width.equalTo(@0).offset(297*fw);
        make.height.equalTo(@0).offset(52*fh);
        make.top.equalTo(@0).offset(450*fh);
    }];
    [_remamberButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.loginButton.mas_left).offset(-5);
        make.top.equalTo(self.loginButton.mas_bottom).offset(10);
        make.width.equalTo(@120);
        make.height.equalTo(@15);
    }];
    [_rightForgetButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.loginButton.mas_right).offset(-10);
        make.centerY.equalTo(self.remamberButton.mas_centerY);
        make.width.equalTo(@50);
        make.height.equalTo(@15);
    }];
    
    [_acountTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_acountImageView.mas_right).offset(10);
        make.right.equalTo(self->_acountMoreButton.mas_left).offset(-5);
        make.centerY.equalTo(self->_acountImageView.mas_centerY);
        make.height.equalTo(@25);
    }];
    [_passTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_passwordImageView.mas_right).offset(10);
        make.right.equalTo(self->_passMoreButton.mas_left).offset(-5);
        make.centerY.equalTo(self->_passwordImageView.mas_centerY);
        make.height.equalTo(@25);
    }];
    
}
- (void)dealloc{
    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"HideTabbarNoti" object:nil];
}
- (void)acountMoreButtonClick:(UIButton *)sender{
    
}
- (void)passMoreButtonClick:(UIButton *)sender{
    
}
- (void)passEarButtonClick:(UIButton *)sender{
    _passTF.secureTextEntry = !_passTF.secureTextEntry;
}
#pragma mark - 获取版本号
- (void)getVersion{
    [SYRequestAPI sy_VersionServiceSuccess:^(id responseObject) {
        
    } fail:^(NSError *error) {
        
    }];
}
//检测到有token直接登录
- (void)loginNoClick{
   [self loginClick:[UIButton new]];
}
- (void)loginClick:(UIButton *)sender{
    //测试账号密码  李春燕@sy31  _acountTF.text   888888 _passTF.text 王莹@sy31
    NSString *acountString =_acountTF.text;
    NSString *passString =_passTF.text;
    
    if (acountString.length == 0) {
        [XSInfoView showInfo:@"请输入账号" onView:self];
        return;
    }
    
    if (passString.length == 0) {
        [XSInfoView showInfo:@"请输入密码" onView:self];
        return;
    }
    
    if (passString.length<6 || passString.length >12) {
        [XSInfoView showInfo:@"请输入6-12位密码" onView:self];
        return;
    }
    
    [MBProgressHUD mj_showMessage:nil toView:self.view];
    [SYRequestAPI sy_loginServiceAccount:acountString password:passString success:^(id responseObject) {
        int code = [[responseObject objectForKey:@"code"] intValue];
        if (code == 10000) {
            self->_userInfoModel = [UserInformationModel yy_modelWithJSON:[responseObject objectForKey:@"data"]];
            //存储token
            [USERDEFAL setObject:self->_userInfoModel.token forKey:TokenDefalut];
            //存储账号
            [USERDEFAL setObject:responseObject forKey:UserInforModelDefalut];
            [USERDEFAL setObject:self->_userInfoModel.accountId forKey:AcountIDDefalut];
            [USERDEFAL setObject:self->_userInfoModel.imid forKey:RYIMidIDDefalut];
            [USERDEFAL setObject:self->_userInfoModel.rongToken forKey:RYTokenDefalut];
            [[SYLoginUserModel sharedSYLoginUserModel] addUserModel:self.userInfoModel];
         //   NSLog(@"ACOUNT ID %@",self->_userInfoModel.accountId);
//            [self boundNoticeAcount];
            [MBProgressHUD mj_hideHUDForView:self.view];
            // 融云服务器链接
            [[RCIM sharedRCIM] connectWithToken:self.userInfoModel.rongToken success:^(NSString *userId) {
                NSLog(@"登陆成功。当前登录的用户ID：%@", userId);
                [USERDEFAL setObject:userId forKey:RYUserIdDefalut];
                [USERDEFAL setObject:self->_userInfoModel.imid forKey:RYIMidIDDefalut];
                [USERDEFAL setObject:self->_userInfoModel.rongToken forKey:RYTokenDefalut];
                [USERDEFAL setObject:self->_userInfoModel.name forKey:RYUserNameDefalut];
                [USERDEFAL setObject:self->_userInfoModel.headPath forKey:RYUserPathDefalut];

                [[RYChatManager shareManager]loginRongCloudWithUserInfo:[[RCUserInfo alloc]initWithUserId:self.userInfoModel.imid name:self.userInfoModel.nickName portrait:self.userInfoModel.headPath] withToken:self.userInfoModel.rongToken];

            } error:^(RCConnectErrorCode status) {
                NSLog(@"登陆的错误码为:%ld", (long)status);
            } tokenIncorrect:^{
                //token过期或者不正确。
                //如果设置了token有效期并且token过期，请重新请求您的服务器获取新的token
                //如果没有设置token有效期却提示token错误，请检查您客户端和服务器的appkey是否匹配，还有检查您获取token的流程。
                NSLog(@"token错误");
            }];
            
            [self.navigationController removeFromParentViewController];
            ViewController *loginHomePageVC = [[ViewController alloc] init];
            MainNavigationController *nav = [[MainNavigationController alloc]initWithRootViewController:loginHomePageVC];
            [UIApplication sharedApplication].keyWindow.rootViewController = nav;
        }else{
//           [XSInfoView showInfo:[responseObject objectForKey:@"msg"] onView:self];
        }
        
    } fail:^(NSError *error) {
        [MBProgressHUD mj_hideHUDForView:self.view];
        [XSInfoView showInfo:error.domain onView:self];
    }];
    
}

- (void)remanberClick:(MinButtonViewBtn *)sender{
    sender.selected = !sender.selected;
    if (sender.selected == YES) {
        sender.topImage.image = [UIImage imageNamed:@"selecSquir"];
        [USERDEFAL setObject:@"YES" forKey:RemaberButtonStateDefalut];
    }else{
        sender.topImage.image = [UIImage imageNamed:@"remanber"];
        [USERDEFAL setObject:@"NO" forKey:RemaberButtonStateDefalut];
    }
//    if (sender.selected == YES) {
//        //记住信息
//        [USERDEFAL setObject:@[_acountTF.text,_passTF.text] forKey:AcountList];
//        [USERDEFAL setObject:_acountTF.text forKey:AcountDefalut];
//        [USERDEFAL setObject:_passTF.text forKey:PassDefalut];
//    }
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}


















@end
